﻿Public Class FormNewService
    Dim DAService As New DSReservationTableAdapters.OTHER_SERVICESTableAdapter
    Dim DACateService As New DSReservationTableAdapters.SERVICE_CATEGORYTableAdapter
    Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        With CboCategoryName
            .DataSource = DACateService.GetData
            .ValueMember = "SERVICE_CAT_ID"
            .DisplayMember = "CATEGORY_NAME"
            .SelectedIndex = -1
        End With
        ' Add any initialization after the InitializeComponent() call.

    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ValidateTextField(TxtSeviceName, "", ErrService) = False Then Exit Sub
        If ValidateCombobox(CboCategoryName, "", ErrService) = False Then Exit Sub
        If ValidateTextField(TxtPrice, "", ErrService) = False Then Exit Sub
        If lblSaveOption.Text = "0" Then
            If MessageBox.Show("តើ អ្នកចង់រក្សាទុក សេវាកម្មថ្មី?", "Servie", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                If DAService.NewService(TxtSeviceName.Text, CboCategoryName.SelectedValue, TxtPrice.Text, 0) = 1 Then
                    Me.DialogResult = Windows.Forms.DialogResult.OK
                Else
                    MessageBox.Show("Error save new server.", "Service", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            End If
        Else
            If MessageBox.Show("Do you want to update service", "Service", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = Windows.Forms.DialogResult.Yes Then
                If DAService.UpdateServiceInfo(TxtSeviceName.Text, CboCategoryName.SelectedValue, TxtPrice.Text, lblSaveOption.Text) = 1 Then
                    Me.DialogResult = Windows.Forms.DialogResult.OK
                Else
                    MessageBox.Show("Error save new server.", "Service", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            End If
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        SetEnglishLanguage()
        Me.Close()
    End Sub

    Private Sub TxtPrice_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtPrice.KeyPress
        SetDisableKeyString(e)
    End Sub

    Private Sub TxtPrice_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtPrice.Enter
        SetEnglishLanguage()
    End Sub

    'Private Sub TxtSeviceName_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtSeviceName.Enter
    '    SetKhmerLanguage()
    'End Sub
End Class